package com.xzz.feign.feignFallback;

import com.xzz.doc.CourseDoc;
import com.xzz.enums.GlobalErrorCode;
import com.xzz.result.JSONResult;
import com.xzz.feign.SearchFeignClient;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class SearchFeignClientFallbackFactory implements FallbackFactory<SearchFeignClient> {
    @Override
    public SearchFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new SearchFeignClient() {
            @Override
            public JSONResult saveCourseDoc(CourseDoc courseDoc) {
                return JSONResult.error(GlobalErrorCode.SERVICE_ERROR);
            }

        };
    }
}